import { axios } from '@/utils/request'
import qs from 'qs';

export function httpAction(url, parameter, method,contentType) {
  return axios({
    url: url,
    method: method,
    data: qs.stringify(parameter),
    headers:{
      'Content-Type': contentType
    }
  })
}

//post
export function postAction(url, parameter) {
  return axios({
    url: url,
    method: 'post',
    data: parameter,
    headers:{
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

//put
export function putAction(url, parameter) {
  return axios({
    url: url,
    method: 'put',
    data: parameter,
    headers:{
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

//get
export function getAction(url, parameter) {
  return axios({
    url: url,
    method: 'get',
    params: parameter
  })
}

//delete
export function deleteAction(url, parameter) {
  return axios({
    url: url,
    method: 'delete',
    params: parameter
  })
}

/**
 * 下载文件 用于excel导出
 * @param url
 * @param parameter
 * @returns {*}
 */
export function downFile(url,parameter){
  return axios({
    url: url,
    params: parameter,
    method:'get' ,
    responseType: 'blob',
    headers:{
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}